package com.ikkong.biz.excel;

import com.google.common.collect.BiMap;
import com.ikkong.biz.model.Classes;
import com.ikkong.biz.model.Student;
import com.ikkong.biz.service.ClassesService;
import com.ikkong.biz.service.StudentService;
import com.ikkong.biz.service.impl.ClassesServiceImpl;
import com.ikkong.biz.service.impl.StudentServiceImpl;
import com.jfinal.kit.StrKit;
import org.jeecgframework.poi.excel.entity.result.ExcelVerifyHanlderResult;
import org.jeecgframework.poi.handler.inter.IExcelVerifyHandler;

import java.util.Map;

/**
 * Created by linyu on 2016/11/14.
 */
public class ExcelStudentVerifyHandlerImpl implements IExcelVerifyHandler<Student>{
    ClassesService service = new ClassesServiceImpl();

    @Override
    public ExcelVerifyHanlderResult verifyHandler(Student stu) {
        StringBuilder builder = new StringBuilder();
        BiMap<String,Integer> maps = service.getClassesNames();
        Integer classid = maps.get(stu.getClass_name());
        if (null == classid){
            builder.append("找不到对应的班级");
        }
        return new ExcelVerifyHanlderResult(false, builder.toString());
    }
}
